package com.xuxueli.applyModules.commont;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.json.JSONUtil;
import com.xuxueli.applyModules.entity.QuartzEntity;
import com.xuxueli.applyModules.utils.DateUtils;
import com.xuxueli.applyModules.utils.testquarts.ServiceBatchSearchJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;
import org.quartz.impl.matchers.GroupMatcher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;

import static org.quartz.TriggerBuilder.newTrigger;

/**
 * 任务调度处理
 */
@Component
@Slf4j
public class QuartzSchedulerCom {

    @Autowired
    private Scheduler scheduler;

    private static final SchedulerFactory SCHEDULER_FACTORY = new StdSchedulerFactory();

    /**
     * 开始执行所有任务,cron表达式
     */
    public void startAllJob() throws SchedulerException {
        Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
        startJob1(scheduler);
        startJob2(scheduler);
        scheduler.start();
    }

    /**
     * 开始执行所有任务,cron表达式
     */
    public void startJob(String name, String group,String cron) throws SchedulerException {
        Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
        // JobDetail 是具体Job实例
        JobDetail jobDetail = JobBuilder.newJob(SchedulerQuartzJob1.class).withIdentity(name, group).build();
        jobDetail.getJobDataMap().put("id", 878L);
        // 基于表达式构建触发器
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cron);
        // CronTrigger表达式触发器 继承于Trigger
        // TriggerBuilder 用于构建触发器实例
        CronTrigger cronTrigger = newTrigger().withIdentity(name, group)
                .withSchedule(cronScheduleBuilder).build();
        scheduler.scheduleJob(jobDetail, cronTrigger);
        scheduler.start();
    }

    /**
     * 获取Job信息
     * @param name
     * @param group
     * state：PAUSED:暂停，NORMAL运行
     */
    public String getJobInfo(String name, String group) throws SchedulerException {
        Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
        TriggerKey triggerKey = new TriggerKey(name, group);
        CronTrigger cronTrigger = (CronTrigger) scheduler.getTrigger(triggerKey);
        return String.format("time:%s,state:%s", cronTrigger.getCronExpression(),
                scheduler.getTriggerState(triggerKey).name());
    }

    /**
     * 修改某个任务的执行时间,cron表达式
     * @param name
     * @param group
     * @param time
     */
    public boolean modifyJob(String name, String group, String time) throws SchedulerException {
        Date date = null;
        Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
        TriggerKey triggerKey = new TriggerKey(name, group);
        CronTrigger cronTrigger = (CronTrigger) scheduler.getTrigger(triggerKey);
        String oldTime = cronTrigger.getCronExpression();
        if (!oldTime.equalsIgnoreCase(time)) {
            CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(time);
            CronTrigger trigger = newTrigger().withIdentity(name, group)
                    .withSchedule(cronScheduleBuilder).build();
            date = scheduler.rescheduleJob(triggerKey, trigger);
        }
        return date != null;
    }

    /**
     * 暂停所有任务
     */
    public void pauseAllJob() throws SchedulerException {
        Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
        scheduler.pauseAll();
    }

    /**
     * 暂停某个任务
     * @param name
     * @param group
     */
    public void pauseJob(String name, String group) throws SchedulerException {
        Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
        JobKey jobKey = new JobKey(name, group);
        JobDetail jobDetail = scheduler.getJobDetail(jobKey);
        if (jobDetail == null)
            return;
        scheduler.pauseJob(jobKey);
    }

    /**
     * 恢复所有任务
     */
    public void resumeAllJob() throws SchedulerException {
        Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
        scheduler.resumeAll();
    }

    /**
     * 恢复某个任务
     * @param name
     * @param group
     */
    public void resumeJob(String name, String group) throws SchedulerException {
        Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
        JobKey jobKey = new JobKey(name, group);
        JobDetail jobDetail = scheduler.getJobDetail(jobKey);
        if (jobDetail == null)
            return;
        scheduler.resumeJob(jobKey);
    }

    /**
     * 删除某个任务
     * @param name
     * @param group
     */
    public void deleteJob(String name, String group) throws SchedulerException {
        Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
        JobKey jobKey = new JobKey(name, group);
        JobDetail jobDetail = scheduler.getJobDetail(jobKey);
        if (jobDetail == null)
            return;
        scheduler.deleteJob(jobKey);
    }

    private void startJob1(Scheduler scheduler) throws SchedulerException {
        // 通过JobBuilder构建JobDetail实例，JobDetail规定只能是实现Job接口的实例
//        Class cls = Class.forName("com.xxx.quartzJob.".concat(quartzJob.getJobName()));
//        JobDetail jobDetails = JobBuilder.newJob(cls) .withIdentity(quartzJob.getJobName(), quartzJob.getUuid()) .build();
        // JobDetail 是具体Job实例
        JobDetail jobDetail = JobBuilder.newJob(SchedulerQuartzJob1.class).withIdentity("job1", "group1").build();
        jobDetail.getJobDataMap().put("id", 878L);
        // 基于表达式构建触发器
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0/5 * * * * ?");
        // CronTrigger表达式触发器 继承于Trigger
        // TriggerBuilder 用于构建触发器实例
        CronTrigger cronTrigger = newTrigger().withIdentity("job1", "group1")
                .withSchedule(cronScheduleBuilder).build();
        scheduler.scheduleJob(jobDetail, cronTrigger);
    }

    private void startJob2(Scheduler scheduler) throws SchedulerException {
        JobDetail jobDetail = JobBuilder.newJob(SchedulerQuartzJob2.class).withIdentity("job2", "group2").build();
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0 0/5 * * * ?");
        CronTrigger cronTrigger = newTrigger().withIdentity("job2", "group2")
                .withSchedule(cronScheduleBuilder).build();
        scheduler.scheduleJob(jobDetail, cronTrigger);
    }

    /**
     * 执行定时任务，
     * @param serviceName
     * @param batchSearchName
     * @param batchSearchId
     * @param scheduleTime
     */
    public void startSchedule(String serviceName, String batchSearchName, Long batchSearchId, String scheduleTime) {
        try {
            Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
            JobKey jobKey = new JobKey(batchSearchName + batchSearchId, serviceName);
            JobDetail jobDetail = JobBuilder.newJob(ServiceBatchSearchJob.class).withIdentity(jobKey).build();
            jobDetail.getJobDataMap().put("id", batchSearchId);
            TriggerKey triggerKey = new TriggerKey(batchSearchName + batchSearchId, serviceName);
            Date startDate;
            if (scheduleTime == null) {
                startDate = new Date();
            } else {
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                startDate = format.parse(scheduleTime);
            }
            //SimpleScheduleBuilder builder = SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(0)
            //    .withRepeatCount(0);
            Trigger trigger = newTrigger().withIdentity(triggerKey).startAt(startDate)
                    //.endAt(DateTimeOffset.Now.AddSeconds(5))
                    .withSchedule(SimpleScheduleBuilder.simpleSchedule()).forJob(jobKey).build();
            scheduler.scheduleJob(jobDetail, trigger);
            scheduler.start();
            log.info("启动定时任务成功: {},{},{}", serviceName, batchSearchId, scheduleTime);
        } catch (ParseException e) {
            log.error("解析定时时间失败,{},{}", scheduleTime, e);
        } catch (SchedulerException e) {
            log.error("启动定时任务失败,{},{}", scheduleTime, e);
        }
    }

    /**
     * 更新定时执行时间
     * @param serviceName
     * @param batchSearchName
     * @param batchSearchId
     * @param scheduleTime
     */
    public void updateSchedule(String serviceName, String batchSearchName, Long batchSearchId, String scheduleTime) {
        try {
            Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
            JobKey jobKey = new JobKey(batchSearchName + batchSearchId, serviceName);
            TriggerKey triggerKey = new TriggerKey(batchSearchName + batchSearchId, serviceName);
            Date startDate;
            if (scheduleTime == null) {
                startDate = new Date();
            } else {
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                startDate = format.parse(scheduleTime);
            }
            //SimpleScheduleBuilder builder = SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(0)
            //  .withRepeatCount(0);
            Trigger trigger = newTrigger().withIdentity(triggerKey).startAt(startDate)
                    .withSchedule(SimpleScheduleBuilder.simpleSchedule()).forJob(jobKey).build();
            scheduler.rescheduleJob(triggerKey, trigger);
            log.info("重置定时任务成功: {},{},{}", serviceName, batchSearchName, scheduleTime);
        } catch (ParseException e) {
            log.error("解析定时时间失败,{},{}", scheduleTime, e);
        } catch (SchedulerException e) {
            log.error("修改定时任务失败,{},{}", scheduleTime, e);
        }
    }

    public void deleteSchedule(String serviceName, String batchSearchName, Long batchSearchId) {
        try {
            Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
            TriggerKey triggerKey = new TriggerKey(batchSearchName + batchSearchId, serviceName);
            JobKey jobKey = new JobKey(batchSearchName + batchSearchId, serviceName);
            scheduler.pauseTrigger(triggerKey);
            scheduler.unscheduleJob(triggerKey);
            scheduler.deleteJob(jobKey);
            log.info("删除定时任务成功: {},{}", serviceName, batchSearchName);
        } catch (SchedulerException e) {
            log.error("删除定时任务失败: {},{},{}", serviceName, batchSearchName, e);
        }
    }

    /**
     * 开始执行所有任务,周期执行
     */
    public void startEaveryJob(String name, String group) throws SchedulerException {
        Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
        // JobDetail 是具体Job实例
        JobDetail jobDetail = JobBuilder.newJob(SchedulerQuartzJob1.class).withIdentity(name, group).build();
        jobDetail.getJobDataMap().put("id", 878L);
        //设置出发时间(每秒执行1次)
        SimpleScheduleBuilder simpleScheduleBuilders = SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(24).repeatForever();
        // 设置出发时间(每1天执行1次)
        SimpleScheduleBuilder simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule().withIntervalInHours(24).repeatForever();
        // TriggerBuilder 用于构建触发器实例
        Trigger trigger = newTrigger().withIdentity(name, group).startNow().withSchedule(simpleScheduleBuilders).build();
        scheduler.scheduleJob(jobDetail, trigger);
        scheduler.start();
    }

    /**
     * 每多少秒执行一次
     * @param name
     * @param group
     * @param seconds
     */
    public void startEachSecJob(String name, String group,int seconds) throws SchedulerException {
        //1、调度器(Schedular)，从工厂中获取调度实例（默认：实例化new StdSchedulerFactory();)
        Scheduler scheduler= StdSchedulerFactory.getDefaultScheduler();
        //2、任务实例（JobDetail）
        JobDetail jobDetail= JobBuilder.newJob(SchedulerQuartzJob2.class) //加载任务类，与HelloJob完成绑定，要求HelloJob实现Job接口
                .withIdentity(name,group) //参数1：任务的名称（唯一实例）；参数2：任务组的名称
                .build();
        //3、触发器（Trigger）
        Trigger trigger= newTrigger()
                .withIdentity(name,group) //参数1：触发器的名称（唯一实例）；参数2：触发器组的名称
                .startNow() //马上启动触发器
                .withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(seconds)) //每5秒执行一次
                .build();
        //让调度器关联任务和触发器，保证按照触发器定义的条件执行任务
        scheduler.scheduleJob(jobDetail,trigger);
        //启动
        scheduler.start();
    }

    /**
     * 添加一个定时任务

     * @param name      任务名。每个任务唯一，不能重复。方便起见，触发器名也设为这个
     * @param group     任务分组。方便起见，触发器分组也设为这个
     * @param jobClass  任务的类类型  eg:TemplateJob.class
     * @param startTime 任务开始时间。传null就是立即开始
     * @param endTime   任务结束时间。如果是一次性任务或永久执行的任务就传null
     * @param cron      时间设置表达式。传null就是一次性任务
     */
    public boolean addJob(String name, String group, Class<? extends Job> jobClass,LocalDateTime startTime, LocalDateTime endTime, String cron, JobDataMap jobDataMap) {
        try {
            // 第一步: 定义一个JobDetail
            JobDetail jobDetail = JobBuilder.newJob(jobClass).
                    withIdentity(name, group).setJobData(jobDataMap).build();
            // 第二步: 设置触发器
            TriggerBuilder<Trigger> triggerBuilder = newTrigger();
            triggerBuilder.withIdentity(name, group);
            triggerBuilder.startAt(toStartDate(startTime));
            triggerBuilder.endAt(toEndDate(endTime)); //设为null则表示不会停止
            if (StringUtils.isNotEmpty(cron)) {
                triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(cron));
            }
            Trigger trigger = triggerBuilder.build();
            //第三步：调度器设置
            Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
            scheduler.scheduleJob(jobDetail, trigger);
            if (!scheduler.isShutdown()) {
                scheduler.start();
            }
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
    /**
     * 修改一个任务的开始时间、结束时间、cron。不改的就传null
     * @param name         任务名。每个任务唯一，不能重复。方便起见，触发器名也设为这个
     * @param group        任务分组。方便起见，触发器分组也设为这个
     * @param newStartTime 新的开始时间
     * @param newEndTime   新的结束时间
     * @param cron         新的时间表达式
     */
    public boolean modifyJobTime(String name, String group, LocalDateTime newStartTime,LocalDateTime newEndTime, String cron) {
        try {
            Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
            TriggerKey triggerKey = TriggerKey.triggerKey(name, group);
            Trigger oldTrigger = scheduler.getTrigger(triggerKey);
            if (oldTrigger == null) {
                return false;
            }
            TriggerBuilder<Trigger> triggerBuilder = newTrigger();
            triggerBuilder.withIdentity(name, group);
            if (newStartTime != null) {
                triggerBuilder.startAt(toStartDate(newStartTime));   // 任务开始时间设定
            } else if (oldTrigger.getStartTime() != null) {
                triggerBuilder.startAt(oldTrigger.getStartTime()); //没有传入新的开始时间就不变
            }
            if (newEndTime != null) {
                triggerBuilder.endAt(toEndDate(newEndTime));   // 任务结束时间设定
            } else if (oldTrigger.getEndTime() != null) {
                triggerBuilder.endAt(oldTrigger.getEndTime()); //没有传入新的结束时间就不变
            }
            if (StringUtils.isNotEmpty(cron)) {
                triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(cron));
            } else if (oldTrigger instanceof CronTrigger) {
                String oldCron = ((CronTrigger) oldTrigger).getCronExpression();
                triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(oldCron));
            }
            Trigger newTrigger = triggerBuilder.build();
            scheduler.rescheduleJob(triggerKey, newTrigger);    // 修改触发时间
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

    /**
     * 取消一个定时任务
     * @param jobName
     * @param groupName
     * @return
     */
    public boolean cancelJob(String jobName, String groupName) {
        try {
            Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
            TriggerKey triggerKey = TriggerKey.triggerKey(jobName, groupName);
            scheduler.pauseTrigger(triggerKey); // 停止触发器
            scheduler.unscheduleJob(triggerKey);    // 移除触发器
            scheduler.deleteJob(JobKey.jobKey(jobName, groupName)); // 删除任务
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        //将数据库中的任务状态设为 取消
        return true;
    }

    /**
     * 查询所有的定时任务
     */
    public List<QuartzEntity> getAllJobs() throws SchedulerException {
        Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
        List<QuartzEntity> quartzJobs = new ArrayList<>();
        try {
            List<String> triggerGroupNames = scheduler.getTriggerGroupNames();
            for (String groupName : triggerGroupNames) {
                GroupMatcher<TriggerKey> groupMatcher = GroupMatcher.groupEquals(groupName);
                Set<TriggerKey> triggerKeySet = scheduler.getTriggerKeys(groupMatcher);
                for (TriggerKey triggerKey : triggerKeySet) {
                    Trigger trigger = scheduler.getTrigger(triggerKey);
                    JobKey jobKey = trigger.getJobKey();
                    JobDetail jobDetail = scheduler.getJobDetail(jobKey);
                    //组装数据
                    QuartzEntity entity = new QuartzEntity();
                    entity.setJobName(jobDetail.getKey().getName());
                    entity.setGroupName(jobDetail.getKey().getGroup());
                    entity.setStartTime(LocalDateTimeUtil.of(trigger.getStartTime()));
                    entity.setEndTime(LocalDateTimeUtil.of(trigger.getStartTime()));
                    entity.setJobClass(jobDetail.getJobClass().getName());
                    if (trigger instanceof CronTrigger) {
                        entity.setCron(((CronTrigger) trigger).getCronExpression());
                    }
                    entity.setJobDataMapJson(JSONUtil.toJsonStr(jobDetail.getJobDataMap()));
                    quartzJobs.add(entity);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return quartzJobs;
    }

    /**
     * 恢复定时任务
     */
    public void recoveryAllJob() {
        List<QuartzEntity> tasks = new ArrayList<>();
        if (tasks != null && tasks.size() > 0) {
            for (QuartzEntity task : tasks) {
                try {
                    JobDataMap jobDataMap = JSONUtil.toBean(task.getJobDataMapJson(), JobDataMap.class);
                    JobDetail jobDetail = JobBuilder.newJob((Class<? extends Job>) Class.forName(task.getJobClass()))
                            .withIdentity(task.getJobName(), task.getGroupName())
                            .setJobData(jobDataMap).build();
                    TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();
                    triggerBuilder.withIdentity(task.getJobName(), task.getGroupName());
                    triggerBuilder.startAt(toStartDate(task.getStartTime()));
                    triggerBuilder.endAt(toEndDate(task.getEndTime()));
                    if (StringUtils.isNotEmpty(task.getCron())) {
                        triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(task.getCron()));
                    }
                    Trigger trigger = triggerBuilder.build();
                    Scheduler scheduler = SCHEDULER_FACTORY.getScheduler();
                    scheduler.scheduleJob(jobDetail, trigger);
                    if (!scheduler.isShutdown()) {
                        scheduler.start();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }

    private static Date toEndDate(LocalDateTime endDateTime) {
        // 结束时间可以为null，所以endDateTime为null，直接返回null即可
        return endDateTime != null ? DateUtil.date(endDateTime) : null;
    }
    private static Date toStartDate(LocalDateTime startDateTime) {
        // startDateTime为空时返回当前时间，表示立即开始
        return startDateTime != null ? DateUtil.date(startDateTime) : new Date();
    }

    /**
     * 初始化触发定时器
     * @param taskId
     * @param taskType
     * @param taskTime
     * @param cycleType
     * @param cycleCron
     */
    private void setJobdetal(Long taskId,Integer taskType,Long taskTime,Integer cycleType,String cycleCron){
        try {
            //构建 job信息
            JobDetail jobDetail = JobBuilder.newJob(TaskExecuteJob.class)
                    .withIdentity("task_job_name_" + taskId, "task_job_group_name")
                    .usingJobData("id", taskId) //设置参数（键值对）
                    .storeDurably()
                    .build();
            //分别根据不同的任务类型 0、定时任务 1、周期任务  构建 trigger
            Trigger trigger = null;
            if (taskType == 0) {
                //定时任务 配合定时任务时间
                trigger = newTrigger()
                        .startNow()
                        .withIdentity("task_job_name_" + taskId, "task_job_group_name")
                        .startAt(new Date(taskTime))
                        .build();
            } else {
                //周期任务  周期任务 0、cron表达式  1、按计算时间
                if (cycleType != null) {
                    switch (cycleType) {
                        case 0: {
                            // 0、cron表达式
                            trigger = newTrigger()
                                    .startNow()
                                    .withIdentity("task_job_name_" + taskId, "task_job_group_name")
                                    .withSchedule(CronScheduleBuilder.cronSchedule(cycleCron))
                                    .build();
                            break;
                        }
                        case 1: {
                            // 1、按计算时间   2_ss 2秒, 2_mm 2分, 2_hh  2小时，2_dd 2天
                            String[] timeArray = cycleCron.split("_");
                            Integer timeNumber = Integer.parseInt(timeArray[0]);
                            String timeUnit = timeArray[1];
                            Integer unitValue = TimeUnitEnum.getValueByCode(timeUnit);
                            trigger = newTrigger()
                                    .withIdentity("task_job_name_" + taskId, "task_job_group_name")
                                    .startAt(new Date())
                                    .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(timeNumber * unitValue).repeatForever()).build();
                            break;
                        }
                        default:
                    }
                }
            }
            //交由Scheduler安排触发
            scheduler.scheduleJob(jobDetail, trigger);
        }catch (Exception ex){
            ex.printStackTrace();
        }
    }

    public static String dateToStr(Date date, String strFormat) {
        SimpleDateFormat sf = new SimpleDateFormat(strFormat);
        String str = sf.format(date);
        return str;
    }

    public static java.sql.Timestamp strToSqlDate(String strDate, String dateFormat) {
        SimpleDateFormat sf = new SimpleDateFormat(dateFormat);
        Date date = null;
        try {
            date = sf.parse(strDate);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        java.sql.Timestamp dateSQL = new java.sql.Timestamp(date.getTime());
        return dateSQL;
    }

    public static void main(String[] args) throws SchedulerException {
        Date current_time = new Date();
        String strDate = dateToStr(current_time, "yyyy-MM-dd HH:mm:ss");
        java.sql.Timestamp op_time = strToSqlDate(strDate, "yyyy-MM-dd HH:mm:ss");
        System.out.println("sql类型timestamp："+op_time);
        Date date = new Date(System.currentTimeMillis());
        System.out.println("当前时间戳时间："+ DateUtils.formatDate(date,"yyyy-MM-dd HH:mm:ss"));
        //QuartzSchedulerCom quartzSchedulerCom = new QuartzSchedulerCom();
        //quartzSchedulerCom.startEachSecJob("sfas","aasfasf",10);
        //quartzSchedulerCom.startEaveryJob("asfa","sdgv");
    }

}
